<!DOCTYPE html>
<html>
<body>
<p id="description">
This test passes if middle mouse clicking on a link where the event handler
focuses a textarea does not paste into the textarea.
</p>
<a href="link" id="link">Link</a>
<textarea id="textarea">Content</textarea>
<script src="../../resources/dump-as-markup.js"></script>
<script>
  
Markup.description(document.getElementById('description').textContent);

document.body.focus();
document.execCommand('SelectAll', false, null);
document.execCommand('Copy', false, null);

var textarea = document.getElementById('textarea');
var linkElement = document.getElementById('link');

linkElement.addEventListener("click", function(e) {
  e.preventDefault();
  textarea.focus();
});

var linkX = linkElement.offsetLeft + linkElement.offsetWidth / 2;
var linkY = linkElement.offsetTop + linkElement.offsetHeight / 2;
    
eventSender.mouseMoveTo(linkX, linkY);
eventSender.mouseDown(1);
eventSender.mouseUp(1);

Markup.dump(textarea, 'After middle click on link');
</script>
</body>
</html>
